package Before826.luckycard;

import java.util.Random;
import java.util.Scanner;


public class week1 {

    private  String admin ;
    private  String password2 ;
    private  Integer card1 ;

    public  static void  main(String[] args) {
        new week1().choice();
    }

    public void choice() {   System.out.println("*****欢迎进入奖客富翁系统*****");
        System.out.println("         1.注册");
        System.out.println("         2.登录");
        System.out.println("         3.抽奖");
        System.out.println("**************************");
        System.out.println("请选择菜单:");
        Scanner scanner = new Scanner(System.in);
        int number = scanner.nextInt();
        switch (number){
            case 1:
                regise();
                break;
            case 2:
                login(admin,password2);
                break;
            case 3:
                cj(card1);
                break;
            default:
                System.out.println("您的输入有误");
        }
    }

    public void regise(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("[奖客富翁系统:注册]");
        System.out.println("请填写个人注册信息:");
        System.out.print("用户名:");
        String username = scanner.next();
        System.out.print("密码:");
        String password = scanner.next();
        System.out.println();
        System.out.println("注册成功,请记好您的会员卡号");
        System.out.println("用户名     密码     会员卡号");
        Random rand=new Random();
        int card=rand.nextInt(9);
        System.out.println(username +"   "+password+"   "+card);
        admin=username;
        password2=password;
        card1 =card;
        cont();
    }
    public void login(String username,String password){
        System.out.println("[奖客富翁系统:登录]");
        Scanner scanner = new Scanner(System.in);

        out:for (int i = 0; i <3 ; i++) {
            System.out.print("请输入用户名:");
            String username1 = scanner.next();
            System.out.print("请输入密码:");
            String password1 = scanner.next();
            System.out.println();
            if(admin.equals(username1)  && password2.equals(password1)){
                System.out.println("欢迎您:"+username1);
                break out;
            }else {
                System.out.println("请重新输入:");
            }
        }
        cont();
    }
    public void cj(int card){
        System.out.println("[奖客富翁系统:抽奖]");
        Random rand = new Random();
        int a=rand.nextInt(9);
        int b=rand.nextInt(9);
        int c=rand.nextInt(9);
        int d=rand.nextInt(9);
        int e=rand.nextInt(9);
        System.out.println("本日的幸运数字为:"+a+b+c+d+e);
        if(a == card1 || b == card1 || c == card1 || d == card1 || e == card1){
            System.out.println("恭喜!您是本日幸运会员.");
        }else{
            System.out.println("抱歉,您不是今日幸运会员.");
        }
        cont();
    }

    public void cont(){
        Scanner scanner = new Scanner(System.in);
        System.out.print("继续吗:(y/n)");
        String A = scanner.next();
        if(A.equals("y")){
            choice();
        }else {
            System.out.println("系统退出,谢谢使用!");
        }
    }
}
